home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-08-27 | 3.7 KB | 143 lines | [TEXT/PJMM] |
- program quickDial;
-
- { QuickDial takes text and dumps AT^m ATD<text>,;H to the modem. This dials the number & hangs up after 2 second. }
- { The program first gets text from STR id 128. This is the dialing prefix prepended to all numbers. }
- { Then it tries to read STR id 129. If that is blank, it tries to read the clipboard for the number. }
- { This way, you can have a general quickdial for all your numbers and special ones to call specific }
- { frequently-used (your mother, for example). }
- { The program will beep if there is no text in STR 129 or the clipboard. }
- { The program is basically meant to go under the System 7 Apple menu. }
- { Unlike the few programs I looked at, I am nice & properly close the serial port when done! }
- { I found the source code of the Busy or Not DA by Kiron Bondale, 1988, quite useful. }
- { Feel free to send email to mblain@aol.com with comments/suggestions/etc... }
- { Matthew Blain, 7/30/93. Public Domain. This source code can be freely distributed. }
- { Version 1.0.1 of 8/1/93 should close the serial port. V 1.0 didn't really. }
- { VErsion 1.0.2 of 8/6 does atdT (tone dial) and also sends a prelimiary AT^m }
- { Version 1.1 of 8/26/93 reads STR's id 128 and 129. If it is blank, it reads the clipboard. }
-
-
- uses
- Serial, Scrap;
-
- var
- InRefNum, OutRefNum, i: integer;
- waiter: longint;
- Err: OSErr;
- numb: str255;
-
- procedure init;
- begin
- { This is the ultimate in facelessness... }
- { Don't even bother initializing everything }
- { InitGraf(@ThePort); InitFonts; InitWindows; InitMenus; TEInit; InitDialogs(nil);}
- { FlushEvents(EveryEvent, 0);}
- end;
-
- procedure openserial;
- var
- config: integer;
- begin
- config := baud1200 + data8 + stop10 + NoParity;
- { Baud1200 should work with any modem! }
- Err := OpenDriver('.AIn', inRefNum);
- Err := OpenDriver('.AOut', OutRefNum);
- Err := SerReset(InRefNum, config);
- Err := SerReset(OutRefNum, config);
- end;
-
- procedure closeserial;
- begin
- { Err := FSClose(OutRefNum);}
- { Err := FSClose(InRefNum);}
- err := closeDriver(InRefNum);
- err := closeDriver(OutRefNum);
- OutRefNum := 0;
- InRefNum := 0;
- end;
-
- procedure getstr (id: integer; var s: str255);
- var
- tHndl: StringHandle;
- begin
- s := '';
- tHndl := GetString(id);
- s := concat(' ', tHndl^^, ' ');
- end;
-
- procedure getnumber (var numb: str255);
- var
- thndl: Handle;
- l, offset: longInt;
- begin
- numb := '';
- getstr(129, numb);
- if (length(numb) = 2) then { 2 = blank. Why, I know not?!!! }
- begin
- tHndl := NewHandle(0);
- l := GetScrap(tHndl, 'TEXT', offset);
- if (offset > 0) then { it returned something useful. }
- begin
- GetIText(tHndl, numb); { cheat conversion }
- end;
- end;
- end;
-
- procedure sendstring (s: string);
- var
- i: integer;
- c: char;
- count: LongInt;
- buffer: packed array[1..10] of char;
- begin
- count := 1;
- for i := 1 to length(s) do
- begin
- buffer[1] := (s[i]);
- Err := FSWrite(OutRefNum, count, @buffer);
- end;
- end;
-
- procedure dialnumber (numb: str255);
- var
- prefix: str255;
- modemstr: str255;
- begin
- prefix := '';
- getstr(128, prefix);
- modemstr := concat('ATD', prefix, numb, ',;H0', chr(13));
- sendstring(modemstr);
- { Any Hayes-compatible modem should be able to handle the semicolon H0 to hang up. }
- end;
-
- { OBSOLETE procedure. 8/26/93 }
- procedure sendhangup;
- var
- ticks: longInt;
- begin
- delay(65, ticks);
- sendstring('+++');
- delay(65, ticks);
- sendstring(concat('ATH0', chr(13)));
- end;
-
-
- { Main }
- begin
- Init;
- getnumber(numb);
- if (length(numb) > 0) then
- begin
- openserial;
- systemtask;
- sendstring(concat('AT', chr(13)));
- { Wake up modem }
- systemtask;
- delay(60, waiter); { wait 1 seconds }
- systemtask;
- dialnumber(numb);
- systemtask;
- closeserial;
- end
- else
- sysbeep(10); { No number found! }
- end.